
// ----------------------------------------------------------------- 以下是分享部分
//分享记录
function saveRecord(actId, type) {
    var json = {
        'ACT_ID': actId,
        'SHARE_TYPE': type,
        'MOBILE': _Global_ == 'web' ? getCookie('userName') : phone
    }
    $.ajax({
        type: "post",
        async: false,
        dataType: "json",
        url: getIp + "/CARNT/Act/createShareRecord.action",
        data: json,
        success: function () {
        }
    });
}
// 点击数
var json = {
    'actId': 20171115
}

$.ajax({
    type: "post",
    async: false,
    dataType: "json",
    url: getIp + "/CARNT/Act/updateActClick.action",
    data: json,
    success: function (data) {
        //slert("ok");
    }
})
/*var title="爆狠招！国际车展门票免费送"; 
 var desc="这个国庆精彩不停！玩转深圳国际车展，猛戳 ";
 var imgUrl="http://121.40.78.200/pic/act/cover/2017101_icon.jpg";
 var linkUrl = "http://carnt.carnettong.com:8088/CARNT/act/1001/main.html";*/
var title;
var desc;
var imgUrl;
var linkUrl;
//分享文案
$.ajax({
    type: "post",
    async: false,
    dataType: "json",
    url: getIp + "/CARNT/ActWeb/getActivityById.action",
    data: {
        ACT_ID: '20171115'
    },
    success: function (data) {
        title = data.RESULT_DATA[0].SHARE_TITLE;
        desc = data.RESULT_DATA[0].SHARE_CONTENT;
        imgUrl = data.RESULT_DATA[0].SHARE_ICON;
        linkUrl = data.RESULT_DATA[0].LINK_URL;
        document.title = title;
        /*console.log(title);
         console.log(desc);
         console.log(imgUrl);
         console.log(linkUrl);*/
    }
});
var timestamp;
var nonceStr;
var signature;
//这个URL是你当前页面的url
var u = navigator.userAgent;
var isAndroids = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; // android终端
var isiOSs = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); // ios终端
var urls = '';
var appid = '';
if (isAndroids) {
    urls = '../../OAuth/getAccess_token.action';
    appid = 'wxf71262a112685c25';
} else if (isiOSs) {
    urls = '../../OAuth/getAccess_tokenIPHONE.action';
    appid = 'wx054c6f61cacfa911';
}
var json = {
    'url': location.href
}
$.ajax({
    type: "post",
    async: false,
    dataType: "json",
    url: urls,
    data: json,
    success: function (data) {
        timestamp = data.NOW_TIME;
        nonceStr = data.NONCESTR;
        signature = data.SKEY;
        wx.config({
            debug: false, // 开启调试模式,false调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
            appId: appid, // 必填，公众号的唯一标识
            timestamp: timestamp, // 必填，生成签名的时间戳
            nonceStr: nonceStr, // 必填，生成签名的随机串
            signature: signature, // 必填，签名，见附录1
            jsApiList: [
                'onMenuShareTimeline',
                'onMenuShareAppMessage',
                'hideOptionMenu',
                'showOptionMenu'
            ]
        });
    }
});
wx.ready(function () {

    // 分享给朋友
    wx.onMenuShareAppMessage({
        title: title,
        desc: desc,
        link: linkUrl,
        imgUrl: imgUrl,
        trigger: function (res) {
        },
        success: function (res) {
            saveRecord(20171115, 1);
        },
        cancel: function (res) {
        },
        fail: function (res) {
            alert(JSON.stringify(res));
        }
    });

    //分享朋友圈
    wx.onMenuShareTimeline({
        title: title,
        desc: desc,
        link: linkUrl,
        imgUrl: imgUrl,
        trigger: function (res) {

        },
        success: function (res) {
            saveRecord(20171115, 1);
        },
        cancel: function (res) {
        },
        fail: function (res) {
            alert(JSON.stringify(res));
        }
    });
});
	